package ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.presentation.controller.admin.devtypes;

import java.util.ArrayList;
import java.util.List;

import ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.persistence.model.AddressType;
import ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.persistence.model.SimpleCommand;

public class SimpleCommandBean {
	
	private SimpleCommand cmd;

	public SimpleCommandBean(SimpleCommand cmd) {
		this.cmd = cmd;
	}
	
	public String getName() {
		return cmd.getName();
	}

	public void setName(String name) {
		cmd.setName(name);
	}

	public Integer getAddress() {
		return cmd.getAddress();
	}

	public void setAddress(Integer address) {
		cmd.setAddress(address);
	}

	public AddressType getMethod() {
		return cmd.getAddressType();
	}

	public void setMethod(AddressType method) {
		cmd.setAddressType(method);
	}

	public Integer getBitnummber() {
		return cmd.getBitOffset();
	}

	public void setBitnummber(Integer bitnummber) {
		cmd.setBitOffset(bitnummber);
	}
	
	public static List<SimpleCommandBean> wrap(	List<SimpleCommand> simpleCommands) {

		List<SimpleCommandBean> ret = new ArrayList<SimpleCommandBean>();
		for (SimpleCommand cmd : simpleCommands) {
			ret.add(new SimpleCommandBean(cmd));
		}
		return ret;
	}
	
	public boolean getDisableBitOffset(){
		return cmd.getAddressType() == AddressType.COIL; 
	}

	public SimpleCommand getCommand() {
		return cmd;
		
	}
}
